<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:comps="http://java.sun.com/jsf/composite/components">
	
<h:body>
		
	<ui:composition template="/resources/templates/mainTemplate.xhtml">
		
		<ui:define name="conteudo">
			
			<h:panelGroup layout="block" styleClass="conteudoInicio">
			
				<h:panelGroup layout="block" styleClass="container">
				
					<h:panelGrid columns="3" width="100%" 
						columnClasses="
							gridVerticalAlignTop columnEsquerda, 
							gridVerticalAlignTop columnCentro, 
							gridVerticalAlignTop columnDireita">
						
						<h:panelGroup layout="block">
						
							<p:panel styleClass="inicioEsquerdaPanel esquerdaPanel">
							
								<f:facet name="header">
								
									<h:panelGrid columns="2" 
										style="width: 100%;"
										columnClasses="inicioEsquerdaPanelTituloLeft, inicioEsquerdaPanelTituloRight">
									
										<p:graphicImage library="images/sistema" name="logo-stat.png" />
										
										<p:graphicImage library="images/sistema" name="logo-stat-texto.png" />
										
									</h:panelGrid>
									
								</f:facet>
								
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.blogsQuantidade gt 1}"
									quantidade="#{PaginaInicialBean.blogsQuantidade}" 
									mensagem="#{locale['estatisticas.blogs']}" />
	
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.blogsQuantidade lt 2}"
									quantidade="#{PaginaInicialBean.blogsQuantidade}" 
									mensagem="#{locale['estatisticas.blog']}" />
			
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.postsQuantidade gt 1}"
									quantidade="#{PaginaInicialBean.postsQuantidade}" 
									mensagem="#{locale['estatisticas.posts']}" />
	
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.postsQuantidade lt 2}"
									quantidade="#{PaginaInicialBean.postsQuantidade}" 
									mensagem="#{locale['estatisticas.post']}" />
									
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.usuariosQuantidade gt 1}"
									quantidade="#{PaginaInicialBean.usuariosQuantidade}" 
									mensagem="#{locale['estatisticas.usuarios']}" />
																	
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.usuariosQuantidade lt 2}"
									quantidade="#{PaginaInicialBean.usuariosQuantidade}" 
									mensagem="#{locale['estatisticas.usuario']}" />
									
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.comentariosQuantidade gt 1}"
									quantidade="#{PaginaInicialBean.comentariosQuantidade}" 
									mensagem="#{locale['estatisticas.comentarios']}" />
	
								<comps:EstatisticaItem 
									rendered="#{PaginaInicialBean.comentariosQuantidade lt 2}"
									quantidade="#{PaginaInicialBean.comentariosQuantidade}" 
									mensagem="#{locale['estatisticas.comentario']}" />
	
							</p:panel>					
							
							<p:panel styleClass="inicioEsquerdaPanel esquerdaPanel">
							
								<f:facet name="header">
								
									<h:panelGrid columns="2" 
										style="width: 100%;"
										columnClasses="inicioEsquerdaPanelTituloLeft, inicioEsquerdaPanelTituloRight">
									
										<p:graphicImage library="images/sistema" name="logo-blog.png" />
										
										<p:graphicImage library="images/sistema" name="logo-blog-texto.png" />
										
									</h:panelGrid>
									
								</f:facet>
								
								<ui:repeat var="blog" 
									value="#{PaginaInicialBean.ultimosBlogsCadastrados}" 
									varStatus="status">
									
									<comps:BlogItem 
										nome="#{blog.nome}" 
										descricao="#{blog.descricao}" 
										dataCriacao="#{blog.dataCriacao}" />
								
								</ui:repeat>								
							
							</p:panel>
							
							<p:panel styleClass="inicioEsquerdaPanel esquerdaPanel">
							
								<f:facet name="header">
								
									<h:panelGrid columns="2" 
										style="width: 100%;"
										columnClasses="inicioEsquerdaPanelTituloLeft, inicioEsquerdaPanelTituloRight">
									
										<p:graphicImage library="images/sistema" name="logo-usuario.png" />
										
										<p:graphicImage library="images/sistema" name="logo-usuario-texto.png" />
										
									</h:panelGrid>
									
								</f:facet>
								
								<ui:repeat var="usuario" value="#{PaginaInicialBean.ultimosUsuariosCadastrados}" varStatus="status">
								
									<comps:UsuarioItem nome="#{usuario.nome}" local="#{usuario.local}" />
								
								</ui:repeat>							
							
							</p:panel>						
												
						</h:panelGroup>
						
						<h:panelGroup style="vertical-align: top;">
							
							<f:facet name="header">
								<h:outputText value="#{locale['sistema.paginaInicial.panels.sobre']}" />
							</f:facet>						
							
							<p:tabView id="conteudoTabView" 
								var="paginaInterna" value="#{PaginaInicialBean.paginasInternas}">
								
							    <p:tab id="paginaTab" title="#{paginaInterna.titulo}">  
								    
							  	  	<h:outputText id="conteudo" value="#{paginaInterna.conteudo}" escape="false" />  
								  		  
							    </p:tab>		    
								
							</p:tabView>
							
						</h:panelGroup>
						
						<h:panelGroup>
						
							<h:panelGroup layout="block" styleClass="cadastrosBox" rendered="#{SessaoBean.autenticado}">
							
								<h:panelGroup layout="block" style="margin-bottom: 10px;">
								
									<h:outputText value="#{locale['sistema.paginaInicial.panels.cadastroBox.bemvindo']} #{SessaoBean.usuarioAutenticado.nome}" />
								
								</h:panelGroup>
								
								<p:commandButton id="cadastrarBtn"
									styleClass="ui-priority-primary cadastrosButtons"
									value="#{locale['sistema.paginaInicial.panels.cadastroBox.acessarPainel']}"
									action="#{PaginaInicialBean.acessarPaineldeControle()}" />
									
							</h:panelGroup>
							
							<h:panelGroup layout="block" styleClass="cadastrosBox" rendered="#{!SessaoBean.autenticado}">
								
								<h:panelGroup layout="block" style="margin-bottom: 10px;">
									<h:outputText value="#{locale['cadastro.mensagem']}" />
								</h:panelGroup>
									
								<h:form id="cadastrosForm">
								
									<h:panelGrid columns="2">
								
										<p:commandButton id="cadastrarBtn"
											styleClass="ui-priority-primary cadastrosButtons"
											value="#{locale['cadastro.botao.novaConta']}"
											update=":cadastroForm"
											action="#{PaginaInicialBean.prepararCadastro()}" />
											
										<p:commandButton id="cadastrarNewsletterBtn"
											styleClass="ui-priority-primary cadastrosButtons"
											value="#{locale['cadastro.botao.cadastrarNewsletter']}"
											update=":cadastroNewsletterForm"
											action="#{PaginaInicialBean.prepararCadastroNewsletter()}" />
									
									</h:panelGrid>
								
								</h:form>							
							
							</h:panelGroup>
							
							<h:panelGroup layout="block" styleClass="pesquisaBlogBox">
								
								<h:panelGroup layout="block" style="margin-bottom: 10px;">
									<h:outputText value="#{locale['pesquisaBlog.mensagem']}" />
								</h:panelGroup>
																
								<p:commandButton id="pesquisaBtn"
									type="button"
									styleClass="cadastrosButtons"
									value="#{locale['pesquisaBlog.botao']}"
									onclick="pesquisarBlogsDlg.show();" />
																		
							</h:panelGroup>							
								
							<p:panel styleClass="noticiasPanel">
							
								<f:facet name="header">
									<h:outputText value="#{locale['sistema.paginaInicial.panels.noticias.titulo']}" />
								</f:facet>
								
								<ui:repeat var="post"
									size="3"
									value="#{PaginaInicialBean.blogOficial.posts}" 
									varStatus="status">
									
									<comps:NoticiaItem 
										titulo="#{post.titulo}" 
										autor="#{post.autor.nome}" 
										texto="#{post.conteudo}"
										data="#{post.data}" />
																
								</ui:repeat>								
								
								<f:facet name="footer">
									
									<h:form id="blogOficialForm">
									
										<h:commandLink id="blogOficialAcessarLink"
											styleClass="acesseOficial"
											ajax="false"
											action="#{BlogBean.exibirBlog(PaginaInicialBean.blogOficial)}">
											<h:outputText value="#{locale['sistema.paginaInicial.panels.noticias.acesseBlog']}" />
										</h:commandLink>
										
									</h:form>
																	
								</f:facet>
							
							</p:panel>			
							
						</h:panelGroup>
					
					</h:panelGrid>
		
				</h:panelGroup>
			
			</h:panelGroup>
				
			<p:dialog id="cadastrarDialogo"
				position="500,80"
				resizable="false" closable="false" draggable="false"
				widgetVar="cadastrarDlg"
				showEffect="slide" hideEffect="slide"
				modal="true">
				
				<f:facet name="header">
					<h:outputText value="#{locale['cadastro.janela.titulo']}" />
				</f:facet>
				
				<h:form id="cadastroForm">
				
					<h:panelGroup layout="block" styleClass="cadastroMessages">
						<h:outputText value="#{locale['cadastro.janela.mensagem']}" style="text-align: justify;" />
						<p:spacer height="10" />
						<p:messages id="cadastroMessages" />
					</h:panelGroup>
					
					<h:panelGrid columns="2">
		
						<p:outputLabel id="nomeLbl" for="nome"
							value="#{locale['cadastro.label.nome']}" />
						<p:inputText id="nome"
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.nome']}"
							styleClass="cadastroInputs"
							label="#{locale['cadastro.label.nome']}"
							value="#{PaginaInicialBean.usuarioNovo.nome}"
							maxlength="100">
							<f:validator validatorId="validator.MinimoPalavrasValidator" />
							<f:attribute name="minimoPalavras" value="2" />
						</p:inputText>
							
						<p:outputLabel id="emailLbl" for="email"
							value="#{locale['cadastro.label.email']}" />
						<p:inputText id="email"
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.email']}"
							styleClass="cadastroInputs"
							label="#{locale['cadastro.label.email']}"
							value="#{PaginaInicialBean.usuarioNovo.email}"
							maxlength="100">
							<f:validator validatorId="validator.EmailValidator" />
						</p:inputText>
	
						<p:outputLabel for="senha1" value="#{locale['cadastro.label.senha']}" />
						<p:password id="senha1" 
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.senha']}"
							styleClass="cadastroInputs"
							match="senha2" 
							validatorMessage="#{locale['cadastro.alterarSenha.naoCorrespondem']}"
							feedback="true"
							inline="true"
							promptLabel="#{locale['cadastro.alterarSenha.senha.prompt']}"
							weakLabel="#{locale['cadastro.alterarSenha.forcaSenha.fraca']}"
							goodLabel="#{locale['cadastro.alterarSenha.forcaSenha.boa']}"
							strongLabel="#{locale['cadastro.alterarSenha.forcaSenha.forte']}"
							value="#{PaginaInicialBean.usuarioNovo.senha}"
							maxlength="32">
							<f:validateLength minimum="8" maximum="32" />
						</p:password>
						
						<p:outputLabel for="senha2" value="#{locale['cadastro.label.senha']}" />
						<p:password id="senha2" 
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.senha']}"
							styleClass="cadastroInputs"
							feedback="true"
							inline="true"
							promptLabel="#{locale['cadastro.alterarSenha.senhaRepetir.prompt']}"
							weakLabel="#{locale['cadastro.alterarSenha.forcaSenha.fraca']}"
							goodLabel="#{locale['cadastro.alterarSenha.forcaSenha.boa']}"
							strongLabel="#{locale['cadastro.alterarSenha.forcaSenha.forte']}"
							value="#{PaginaInicialBean.usuarioNovo.senha}"
							maxlength="32">
							<f:validateLength minimum="8" maximum="32" />
						</p:password>
						
						<p:outputLabel id="localLbl" for="local"
							value="#{locale['cadastro.label.local']}" />
						<p:inputText id="local"
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.local']}"
							styleClass="cadastroInputs"
							label="#{locale['cadastro.label.local']}"
							value="#{PaginaInicialBean.usuarioNovo.local}"
							maxlength="100">
						</p:inputText>					
						
						<p:outputLabel for="sexo" value="#{locale['cadastro.label.sexo']}" />
						<p:selectOneRadio id="sexo"
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.sexo']}"
							styleClass="cadastroInputs"
							value="#{PaginaInicialBean.usuarioNovo.sexo}">
							<f:selectItems value="#{PaginaInicialBean.sexoList}" />
						</p:selectOneRadio>
						
						<p:outputLabel id="dataNascimentoLbl" for="dataNascimento"
							value="#{locale['cadastro.label.dataNascimento']}" />
						<p:calendar id="dataNascimento"
							required="true"
							requiredMessage="#{locale['cadastro.validacao.requerido.dataNascimento']}"
							pattern="dd/MM/yyyy"
							locale="pt_BR"
							mindate="01/01/1900" maxdate="31/12/1994"
							yearRange="c-100:c+100"
							navigator="true"
							value="#{PaginaInicialBean.usuarioNovo.dataNascimento}" showOn="button" />
						
					</h:panelGrid>
					
					<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
					
						<p:commandButton id="cadastrarBtn"
							styleClass="ui-priority-primary"
							update="cadastroForm"
							value="#{locale['cadastro.botao.cadastrar.label']}"
							action="#{PaginaInicialBean.cadastrar()}" />
							
						<p:commandButton id="cancelarCadastroBtn"
							update="cadastroForm"
							value="#{locale['cadastro.botao.cancelarCadastro.label']}"
							action="#{PaginaInicialBean.cancelarCadastro()}"
							immediate="true" />
						
					</h:panelGroup>
				
				</h:form>
				
			</p:dialog>
			
			<p:dialog id="cadastrarNewsletterDialogo"
				position="center"
				resizable="false" closable="false" draggable="false"
				widgetVar="cadastrarNewsletterDlg"
				showEffect="slide" hideEffect="slide"
				modal="true">
				
				<f:facet name="header">
					<h:outputText value="#{locale['cadastroNewsletter.janela.titulo']}" />
				</f:facet>
				
				<h:form id="cadastroNewsletterForm">
				
					<h:panelGroup layout="block" styleClass="cadastroNewsletterMessages">
						<h:outputText value="#{locale['cadastroNewsletter.janela.mensagem']}" />
						<p:spacer height="10" />
						<p:messages id="cadastroNewsletterMessages" />
					</h:panelGroup>
					
					<h:panelGrid columns="2">
		
						<p:outputLabel id="nomeNewsletterLbl" for="nomeNewsletter"
							value="#{locale['cadastro.label.nome']}" />
						<p:inputText id="nomeNewsletter"
							required="true"
							requiredMessage="#{locale['cadastroNewsletter.validacao.requerido.nome']}"
							styleClass="cadastroInputs"
							label="#{locale['cadastro.label.nome']}"
							value="#{PaginaInicialBean.pessoaNewsletter.nome}">
							<f:validator validatorId="validator.MinimoPalavrasValidator" />
							<f:attribute name="minimoPalavras" value="2" />
						</p:inputText>
							
						<p:outputLabel id="emailNewsletterLbl" for="emailNewsletter"
							value="#{locale['cadastro.label.email']}" />
						<p:inputText id="emailNewsletter"
							required="true"
							requiredMessage="#{locale['cadastroNewsletter.validacao.requerido.email']}"
							styleClass="cadastroInputs"
							label="#{locale['cadastro.label.email']}"
							value="#{PaginaInicialBean.pessoaNewsletter.email}">
							<f:validator validatorId="validator.EmailValidator" />
						</p:inputText>
						
					</h:panelGrid>
					
					<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
					
						<p:commandButton id="cadastrarNewsletterBtn"
							styleClass="ui-priority-primary"
							update="cadastroNewsletterForm"
							value="#{locale['cadastro.botao.cadastrar.label']}"
							action="#{PaginaInicialBean.cadastrarNewsletter()}" />
							
						<p:commandButton id="cancelarNewsletterBtn"
							update="cadastroNewsletterForm"
							value="#{locale['cadastro.botao.cancelar.label']}"
							action="#{PaginaInicialBean.cancelarCadastroNewsletter()}"
							immediate="true" />
							
					</h:panelGroup>
				
				</h:form>
			
			</p:dialog>
				
			<p:dialog id="pesquisarBlogsDialogo"
			 	width="1100"
				resizable="false" closable="true" draggable="false"
				widgetVar="pesquisarBlogsDlg"
				showEffect="slide" hideEffect="slide"
				modal="true">
				
				<f:facet name="header">
					<h:outputText value="#{locale['sistema.paginaInicial.panels.pesquisaBlogs.titulo']}" />
				</f:facet>
	
				<h:form id="pesquisaBlogsForm">
												
						<h:panelGrid columns="13" styleClass="filtrosPesquisa">
												
							<p:outputLabel id="nomeBlogPesquisaLbl"
								value="#{locale['blog.label.nome']}: "
								for="nomeBlogPesquisa" />
							<p:inputText id="nomeBlogPesquisa"
								size="28" value="#{PaginaInicialBean.nomeBlogPesquisa}" />
												
							<p:spacer width="8" />
											
							<p:outputLabel id="tituloBlogPesquisaLbl"
								value="#{locale['blog.label.titulo']}: "
								for="tituloBlogPesquisa" />
							<p:inputText id="tituloBlogPesquisa"
								size="28" value="#{PaginaInicialBean.tituloBlogPesquisa}" />
								
							<p:spacer width="8" />
											
							<p:outputLabel id="descricaoBlogPesquisaLbl"
								value="#{locale['blog.label.descricao']}: "
								for="descricaoBlogPesquisa" />
							<p:inputText id="descricaoBlogPesquisa"
								size="28" value="#{PaginaInicialBean.descricaoBlogPesquisa}" />
													
							<p:spacer width="8" />
													
							<p:outputLabel id="assuntosBlogPesquisaLbl"
								value="#{locale['blog.label.assuntos']}: "
								for="assuntosBlogPesquisa" />
							<p:inputText id="assuntosBlogPesquisa"
								size="28" value="#{PaginaInicialBean.assuntosBlogPesquisa}" />
								
							<p:spacer width="8" />
							
							<p:commandButton id="pesquisar" 
								update="pesquisaBlogsForm:blogsDataTable"
								styleClass="ui-priority-primary"
								value="#{locale['crud.pesquisa.botao.pesquisar']}"
								icon="icon-search"
								onclick="pesquisarBlogsDlg.initPosition();"
								action="#{PaginaInicialBean.pesquisarBlogs()}" />																											
									
						</h:panelGrid>									
																			
					<p:spacer height="10" />
										
					<p:dataTable id="blogsDataTable"
						widgetVar="blogsTable"
						value="#{PaginaInicialBean.blogsPesquisados}"
						var="blog"
						paginator="true" rows="10"
						paginatorPosition="bottom"
						paginatorAlwaysVisible="true"
						emptyMessage="#{locale['crud.pesquisa.lista.semResultado']}">
						
						<f:facet name="header">
							<h:outputText value="#{locale['sistema.paginaInicial.panels.pesquisaBlogs.tituloResultado']}" />
						</f:facet>
								
						<p:column sortBy="{#{blog.nome}}">
							
							<f:facet name="header">
								<h:outputText value="#{locale['blog.label.nome']}" />
							</f:facet>
							<h:outputText value="#{blog.nome}" />
							
						</p:column>
							
						<p:column sortBy="{#{blog.titulo}}">
								
							<f:facet name="header">
								<h:outputText value="#{locale['blog.label.titulo']}" />
							</f:facet>
							<h:outputText value="#{blog.titulo}" />
								
						</p:column>									
								
						<p:column sortBy="{#{blog.descricao}}">
										
							<f:facet name="header">
								<h:outputText value="#{locale['blog.label.descricao']}" />
							</f:facet>
							<h:outputText value="#{blog.descricao}" />
											
						</p:column>
										
						<p:column sortBy="{#{blog.assuntos}}">
									
							<f:facet name="header">
								<h:outputText value="#{locale['blog.label.assuntos']}" />
							</f:facet>
							<h:outputText value="#{blog.assuntos}" />
											
						</p:column>													
										
						<p:column sortBy="{#{blog.dono.nome}}">
										
							<f:facet name="header">
								<h:outputText value="#{locale['blog.label.dono']}" />
							</f:facet>
							<h:outputText value="#{blog.dono.nome}" />
											
						</p:column>
										
						<p:column style="text-align: center;">
									
							<f:facet name="header">
								<h:outputText value="#{locale['crud.botao.acessar']}" />
							</f:facet>
									
							<p:commandButton id="acessarBlogBtn"
								icon="ui-icon-circle-arrow-e" ajax="false"
								action="#{BlogBean.exibirBlog(blog)}">
							</p:commandButton>
								
						</p:column>
	
					</p:dataTable>
								
				</h:form>		
			
			</p:dialog>	
			
		</ui:define>
		
	</ui:composition>
										
</h:body>

</html>